home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Browsers, Managers & Extensions
/
Firefox Backup Extension 6.0.3
/
chrome
/
febe.jar
/
content
/
febeQuickBu.js
< prev
next >
Wrap
Text File
|
2008-08-18
|
8KB
|
226 lines
// author: Chuck Baker
// contact: febe@customsoftwareconsult.com
// Version 6.0
var febeNameGuidxref = {};
function febeBuildList(){
// Clear the list
var theList = document.getElementById("febeExtList");
var children = theList.childNodes;
var n = children.length;
// Clear existing items
for (var i = 0; i < n; i++) {
theList.removeChild(children[0]);
}//for
febeQuBuList();
// Sort the list
var sortArray = [];
for(var i in febeExtensionsList){
sortArray.push(febeExtensionsList[i].Name);
}//for
sortArray.sort();
for(var i in sortArray){
var data = febeExtensionsList[febeNameGuidxref[sortArray[i]]];
var row = document.createElement('listitem');
row.setAttribute('id', data.Guid );
row.setAttribute('type', "checkbox" );
var fxver = "(Fx ver "+data.Minversion+" - "+data.Maxversion+")";
row.setAttribute('label', data.Name+"{"+data.Version+"} "+fxver );
row.setAttribute('checked', "false" );
if(data.Type == 2){
row.setAttribute('style', "color: blue;" );
}else{
row.setAttribute('style', "color: green;" );
}//if
if(data.isDisabled) row.setAttribute('style', "color: grey;" );
theList.appendChild( row );
}//for
document.getElementById("febeSelectAllID").setAttribute("disabled","false");
document.getElementById("febeDeselectAllID").setAttribute("disabled","false");
return true;
}//febeBuListWindow()
function febeSelect(bool){
// Select/deselect all
for(var i in febeExtensionsList){
var item = document.getElementById(i);
if(item){item.setAttribute("checked",bool);}
}//for
}//febeSelect()
function febeSaveList(){
}//febeSaveList()
function febeQuBuList(){
//Get a list of all installed extensions/themes
febeProfDir = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
febeProfDir.append("extensions");
var extDir = febeProfDir.clone();
var entries = extDir.directoryEntries;
febeExtensionsList = {};
while(entries.hasMoreElements()){
var entry = entries.getNext();
entry.QueryInterface(Components.interfaces.nsIFile);
if(!entry.isDirectory()){continue;} // Don't process junk in the extension directory
var guid = entry.leafName;
var thisExt = new febeExtInfo(guid);
if(!thisExt) continue;
var eType = thisExt.type; // 2=Extension, 4=Theme
if(eType != 2 && eType != 4){continue;} // Not an extension or theme ... what is it?
var ext = new febeExtObj;
ext.Name = thisExt.name;
ext.Type = eType;
ext.Version = thisExt.version;
ext.Icon = thisExt.iconURL;
ext.Home = thisExt.homepageURL;
ext.Guid = guid;
ext.verified = false;
ext.Include = false;
ext.isDisabled = thisExt.isDisabled;
ext.Minversion = thisExt.minVersion;
ext.Maxversion = thisExt.maxVersion;
var ePath = extDir.clone();
ePath.append(thisExt.guid)
ext.Path = ePath.path;
febeExtensionsList[guid] = ext;
febeNameGuidxref[thisExt.name] = guid;
var tmp = "";
tmp=febeExtensionsList[thisExt.guid].Name+"\n";
tmp+=febeExtensionsList[thisExt.guid].Version+"\n";
tmp+=febeExtensionsList[thisExt.guid].Path+"\n";
tmp+=febeExtensionsList[thisExt.guid].Icon+"\n";
tmp+=febeExtensionsList[thisExt.guid].Home+"\n";
tmp+=febeExtensionsList[thisExt.guid].Guid+"\n";
tmp+=febeExtensionsList[thisExt.guid].verified+"\n";
tmp+=febeExtensionsList[thisExt.guid].Include+"\n";
tmp+="type: "+eType+"\n";
//alert(tmp)
//if(i < 3) alert(tmp);
}//while
}//febeQuBuList()
function febeQuickBu(){
febeProfDir = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
febeProfDir.append("extensions");
var combined = document.getElementById("febeCreateSingleXPI").checked;
var combinedName = document.getElementById("febeCreateSingleXPIname").value +".xpi";
febeExBuDir = document.getElementById("febeQuickBuDir").value;
if(combined){
febeTmpDir = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
febeTmpDir.initWithPath(febeExBuDir);
febeTmpDir.append("QBuTmp")
if ((febeTmpDir.exists() && febeTmpDir.isDirectory())){febeTmpDir.remove(true);}
febeTmpDir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
}//if
var cnt = 0;
for(var i in febeExtensionsList){
var which = document.getElementById(i);
if(which.getAttribute("checked") != "true"){continue;}
var item = febeExtensionsList[i]
var extDir = febeProfDir.clone();
febeExtExt = ".xpi";
if(item.Type == 4){febeExtExt = ".jar"};
var extName = item.Name;
var extVer = febeStripSpaces(item.Version);
var extBuName = febeStripSpaces(extName)+"{" + extVer + "}"+febeExtExt;
var srcName = extDir.clone();
srcName.append(i);
srcName = srcName.path;
var destDir = febeExBuDir;
if(combined){destDir = febeTmpDir.path;}
febeZip(srcName,destDir,extBuName);
which.setAttribute("checked", false)
cnt++;
}//for
//alert(febeZipFinished)
if(combined){
febeProfDir = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
febeProfDir.append("extensions");
febeProfDir.append(FEBE_GUID);
febeProfDir.append("!install.rdf");
var sourcefile = febeProfDir.path;
var destDir = febeTmpDir.path;
var dName = "install.rdf";
febeCopyFile(sourcefile,destDir,dName); // Copy the install.rdf for the combined package
febeZip(febeTmpDir.path,febeExBuDir,combinedName);
//while(!febeZipFinished){;}
var tmp = febeMsg[218].replace(/%NUM%/,cnt);
tmp = tmp.replace(/%FNAME%/,combinedName);
febeAlert(tmp);
febeTmpDir.remove(true);
}else{
var tmp = febeMsg[217].replace(/%NUM%/,cnt);
febeAlert(tmp);
}//if
return true;
}//febeQuickBu()
function febeQuickBuLoad(){
febeSetMsgs();
var qbuDir = febeMsg[216];
var prefName = "extensions.febe.quickBuDir";
if(febePrefs.prefHasUserValue(prefName)){
qbuDir = febeGetUnicharPref(prefName);
}else{
var prefName = "extensions.febe.extBUdir";
if(febePrefs.prefHasUserValue(prefName)){
qbuDir =febeGetUnicharPref(prefName);
}//if
}//if
document.getElementById("febeQuickBuDir").value = qbuDir;
febeBuildList();
}//febeQuickBuLoad()
function febeCreateSingleXPIcheck(that){
document.getElementById("febeCreateSingleXPIbox").hidden = !that.checked;
//sizeToContent();
}//febeCreateSingleXPIcheck()
function febeQuickBuBrowse(){
// Select Quick backup destinaton directory
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, febeMsg[216], nsIFilePicker.modeGetFolder);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
// Set default directory to current backup directory
var qbuDir = document.getElementById("febeQuickBuDir").value;
var dd = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
dd.initWithPath(qbuDir);
fp.displayDirectory = dd;
var rv = fp.show();
if (rv == nsIFilePicker.returnOK){
rv = fp.file;
qbuDir = rv.path;
febeSetUnicharPref("extensions.febe.quickBuDir", qbuDir);
document.getElementById("febeQuickBuDir").value = qbuDir;
}//if
return true;
}//febeQuickBuBrowse()